home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1034 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  5.4 KB

  1. Date: Thu, 17 Feb 94 23:43:07 PST
  2. From: hyc@hanauma.jpl.nasa.gov (Howard Chu)
  3. Message-Id: <9402180743.AA10650@hanauma.jpl.nasa.gov>
  4. To: mint@atari.archive.umich.edu
  5. Subject: Working Psigintr call...
  6.  
  7. Ok, life is much happier with MiNT 1.10. Here's my working version of the
  8. stuff I sent out for comment before. Psigintr takes two arguments, an
  9. exception vector number, and a signal number. It uses setexc to point the
  10. exception handler for the given vector at a routine which just calls
  11. post_sig. So, the requested signal is sent to the process that originally
  12. called Psigintr... If you would care to see my double-buffered direct-to-disk
  13. sound play/record program that uses this, drop me a line.
  14.  -- Howard
  15.  
  16. *** 1.1    1994/02/17 16:16:26
  17. --- dos.c    1994/02/17 16:17:52
  18. ***************
  19. *** 603,605 ****
  20. --- 603,606 ----
  21.       dos_tab[0x13c] = s_alert;
  22.       dos_tab[0x13d] = t_malarm;
  23. +     dos_tab[0x13e] = p_sigintr;
  24.   }
  25. *** 1.1    1994/02/17 20:17:08
  26. --- dosmem.c    1994/02/17 20:19:58
  27. ***************
  28. *** 736,739 ****
  29. --- 736,741 ----
  30.       }
  31.   
  32. + /* cancel all user-specified interrupt signals */
  33. +     cancelsigintrs();
  34.   /* cancel all pending timeouts for this process */
  35.       cancelalltimeouts();
  36. *** 1.1    1994/02/17 16:16:26
  37. --- dossig.c    1994/02/17 23:35:26
  38. ***************
  39. *** 211,212 ****
  40. --- 211,319 ----
  41.       return 0;
  42.   }
  43. + /*
  44. +  * p_sigintr: Set an exception vector to send us the specified signal.
  45. +  */
  46. + typedef struct usig {
  47. +     int vec;        /* exception vector number */
  48. +     int sig;        /* signal to send */
  49. +     PROC *proc;        /* process to get signal */
  50. +     long oldv;        /* old exception vector value */
  51. +     struct usig *next;    /* next entry ... */
  52. + } usig;
  53. + static usig *usiglst;
  54. + extern long mcpu;
  55. + long ARGS_ON_STACK
  56. + p_sigintr(vec, sig)
  57. +     int vec;
  58. +     int sig;
  59. + {
  60. +     extern void new_intr();    /* in intr.spp */
  61. +     long vec2;
  62. +     usig *new;
  63. +     if (!sig)        /* ignore signal 0 */
  64. +         return 0;
  65. +     vec2 = (long) new_intr;
  66. + #ifndef ONLY030
  67. +     if (mcpu == 0)            /* put vector number in high */
  68. +         vec2 |= vec << 24;    /* byte of vector address */
  69. + #endif
  70. +     new = kmalloc(sizeof(usig));
  71. +     if (!new)            /* hope this never happens...! */
  72. +         return ENSMEM;
  73. +     new->vec = vec;
  74. +     new->sig = sig;
  75. +     new->proc = curproc;
  76. +     new->next = usiglst;        /* simple unsorted list... */
  77. +     usiglst = new;
  78. +     new->oldv = setexc(vec, vec2);
  79. +     return new->oldv;
  80. + }
  81. + /*
  82. +  * Find the process that requested this interrupt, and send it a signal.
  83. +  * Called at interrupt time by new_intr() from intr.spp, with interrupt
  84. +  * vector number on the stack.
  85. +  */
  86. + void ARGS_ON_STACK
  87. + sig_user(vec)
  88. +     int vec;
  89. + {
  90. +     usig *ptr;
  91. +     for (ptr = usiglst; ptr; ptr=ptr->next)
  92. +         if (vec == ptr->vec) {
  93. +             if (ptr->proc->wait_q != ZOMBIE_Q &&
  94. +                 ptr->proc->wait_q != TSR_Q) {
  95. +                 post_sig(ptr->proc, ptr->sig);
  96. +             }
  97. + #if 0    /* Search entire list, to allow multiple processes to respond to
  98. +        the same interrupt. (Why/when would you want that?) */
  99. +             break;
  100. + #endif
  101. +         }
  102. +     /*
  103. +      * Clear in-service bit for ST MFP interrupts
  104. +      */
  105. +     if (vec >= 64 && vec < 80) {
  106. +         char *mfp, c;
  107. +         if (vec < 72)        /* Register B */
  108. +             mfp = (char *)0xfffffa11L;
  109. +         else            /* Register A */
  110. +             mfp = (char *)0xfffffa0fL;
  111. +         c = 1 << (vec & 7);
  112. +         *mfp = ~c;
  113. +     }
  114. + }
  115. + /*
  116. +  * cancelsigintrs: remove any interrupts requested by this process, called
  117. +  * at process termination.
  118. +  */
  119. + void ARGS_ON_STACK
  120. + cancelsigintrs()
  121. + {
  122. +     usig *ptr, *old;
  123. +     short s = spl7();
  124. +     for (old=NULL, ptr=usiglst; ptr; old=ptr, ptr=ptr->next)
  125. +         if (ptr->proc == curproc) {
  126. +             setexc(ptr->vec, ptr->oldv);
  127. +             if (old)
  128. +                 old->next = ptr->next;
  129. +             else
  130. +                 usiglst = ptr->next;
  131. +             kfree(ptr);
  132. +         }
  133. +     spl(s);
  134. + }
  135. *** 1.1    1994/02/17 16:16:26
  136. --- intr.spp    1994/02/17 23:27:04
  137. ***************
  138. *** 71,75 ****
  139.       clr.w    -(sp)            ; yes, long frames: push a frame word
  140.   L_short1:
  141. !     pea    L_comeback        ; push fake PC
  142.       move.w    sr,-(sp)        ; push status register
  143.       move.l    _old_vbl+8,-(sp)    ; go service the interrupt
  144. --- 71,75 ----
  145.       clr.w    -(sp)            ; yes, long frames: push a frame word
  146.   L_short1:
  147. !     pea    L_comeback(pc)        ; push fake PC
  148.       move.w    sr,-(sp)        ; push status register
  149.       move.l    _old_vbl+8,-(sp)    ; go service the interrupt
  150. ***************
  151. *** 235,238 ****
  152. --- 235,268 ----
  153.       
  154.   ;
  155. + ; Generic routine for handling any user-specified interrupts. On 68000, the
  156. + ; vector number is stored in the high byte of the program counter.
  157. + ;
  158. +     XDEF    _new_intr
  159. + _new_intr:
  160. +     movem.l    d0-d2/a0-a2,-(sp)    ; save regs
  161. + %ifndef ONLY030
  162. +     tst.w    ($59e.w)    ; is frame format on stack?
  163. +     bne.s    nvec        ; yes, go use it
  164. +     bsr.s    ndummy        ; push PC to stack
  165. +     nop
  166. + ndummy:    
  167. +     move.w    (sp)+,d0    ; pop hi(PC) to d0
  168. +     addq.w    #2,sp        ; pop lo(PC) off stack
  169. +     lsr.w    #8,d0        ; move hi byte to vector number
  170. +     bra.s    ngot        ; continue
  171. + nvec:
  172. + %endif
  173. +     move.w    30(sp),d0    ; get frame word
  174. +     lsr.w    #2,d0        ; move vector offset to vector number
  175. + ngot:
  176. +     move.w    d0,-(sp)    ; push vector offset
  177. +     jsr    _sig_user    ; send signal
  178. +     addq.w    #2,sp            ; pop vector offset
  179. +     movem.l    (sp)+,d0-d2/a0-a2    ; restore regs
  180. +     rte
  181. + ;
  182.   ; New bus error handler for memory protection: get the ssp and
  183.   ; put it in the proc structure before calling
  184. *** 1.1    1994/02/17 16:33:50
  185. --- proto.h    1994/02/17 20:30:28
  186. ***************
  187. *** 167,170 ****
  188. --- 167,172 ----
  189.   long ARGS_ON_STACK p_sigpending P_((void));
  190.   long ARGS_ON_STACK p_sigpause P_((ulong mask));
  191. + long ARGS_ON_STACK p_sigintr P_((int vec, int sig));
  192. + void cancelsigintrs P_((void));
  193.   
  194.   /* filesys.c */
  195.